Singly linked list

SNode ---> T element + SNode next

2 special nodes: head + tail (The node whose next pointer is equal to null)

Plan of action: 
1. Create a Position ADT (interface): getElement
2. Create an SNode as a class implementing the Position interface
3. Create the SList ADT: 
int size()
boolean isEmpty()

void insertAtHead(T e)
void insertAtTail(T e)
T removeFromHead() throws EmptyListException
T removeFromTail() throws EmptyListException // O(n) implementation
T getHead() throws EmptyListException
T getTail() throws EmptyListException

4. Create SinglyLinkedList as a class implementing the SList interface

1: new head

    head       tail
1 -> 2 -> 3 -> 4

head=tail->
1


5: new tail
newSNode: 5 -> null
head	      tail
2 -> 3 -> 4 -> 5 -> null

- Linked list leetcode: reverse linked list

















5. Use the singly linked list to create a stack data structure
Note: top element is placed at the head of the singly linked list ---> 
Why? removeFromHead and insertAtHead have a O(1) time complexity









